#include "TimeReaper.h"

CTimeReaper::CTimeReaper(void):m_time(this, 0){}

CTimeReaper::~CTimeReaper(void){}

void CTimeReaper::reaperUpdate(void)
{
	int numberOfParticle=m_particleSystem->m_numberOfParticle;
	int numberOfElementPerParticle=8;
	//float time=m_particleSystem->m_applicationTime.getValue();
	float time=m_particleSystem->m_time.getValue();
	float* arrayOfParticle = m_particleSystem->m_arrayOfParticles;

	for(int i=6; i<numberOfParticle; i+=numberOfElementPerParticle)
	{
		if(arrayOfParticle[i+1]!=-1)
		{
			if(arrayOfParticle[i]+m_lifeSpan<time)
			{
				arrayOfParticle[i-1]=-1;
				arrayOfParticle[i-2]=-1;
				arrayOfParticle[i-3]=-1;
				arrayOfParticle[i-4]=-1;
				arrayOfParticle[i-5]=-1;
				arrayOfParticle[i-6]=-1;
				arrayOfParticle[i-7]=-1;
			}
		}
	}
}